fix: prevent write_to_file from executing with missing content parameter#12080
fix: prevent write_to_file from executing with missing content parameter#12080roomote-v0[bot] wants to merge 2 commits intomainfrom
Conversation
When finalizeStreamingToolCall returns null (malformed/incomplete args from LLM), the existing partial ToolUse block was promoted to non-partial while retaining stale nativeArgs from partial parsing. The partial parser for write_to_file used OR logic (path || content), allowing nativeArgs to be set with only path present. This bypassed the safety check in presentAssistantMessage that guards against missing nativeArgs. Two fixes applied: 1. Clear nativeArgs when promoting failed finalization blocks to complete in Task.ts (both finalization paths). This ensures the safety check in presentAssistantMessage properly catches invalid tool calls. 2. Tighten partial write_to_file nativeArgs in NativeToolCallParser to require both path AND content (handlePartial reads from params, not nativeArgs, so this is safe). Closes #12079
cb70c75 to
4f0c595
Compare
|
@roomote this step is failing https://github.com/RooCodeInc/Roo-Code/actions/runs/24240632367/job/70774058524?pr=12080 can you check |
The failing All code-related CI checks for this PR pass:
No code changes needed here. |
|
@roomote still the status says "some checks were not successful" |
I investigated the failing check. The only failure is the All actual code quality checks pass:
No code changes are needed in this PR to address the |
|
@roomote looks like this MR wont be considered to review till all the checks are passed per what i see in reviewer status |
The only failing check was |
Related GitHub Issue
Closes: #12079
Description
This PR attempts to address Issue #12079. Feedback and guidance are welcome.
Root Cause: When
finalizeStreamingToolCallreturns null (because the LLM sent malformed or incomplete arguments), the existing partialToolUseblock gets promoted to non-partial while retaining stalenativeArgsfrom partial parsing. The partial parser forwrite_to_fileused OR logic (path || content), allowingnativeArgsto be set with onlypathpresent andcontent: undefined. This bypassed the safety check inpresentAssistantMessagethat guards against missingnativeArgs, causingWriteToFileTool.executeto receive params withcontent: undefined.Fixes applied:
Task.ts (two locations): Clear
nativeArgswhen promoting failed finalization blocks to complete. This ensures the safety check inpresentAssistantMessage(!block.nativeArgs) properly catches these as invalid tool calls and returns a structured error to the LLM.NativeToolCallParser.ts: Tighten partial
write_to_filenativeArgs to require bothpathANDcontent(changed||to&&). This is safe becausehandlePartialreads fromblock.params, notnativeArgs.Test Procedure
NativeToolCallParser.spec.tscovering:Pre-Submission Checklist
Documentation Updates
Interactively review PR in Roo Code Cloud